package edu.hzit.data.service.impl;

import edu.hzit.data.entity.Income;
import edu.hzit.data.mapper.IncomeMapper;
import edu.hzit.data.service.IncomeService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class IncomeServiceImpl implements IncomeService {
    @Resource
    private IncomeMapper incomeMapper;
    @Override
    public int insert(Income income) {
        return incomeMapper.insert(income);
    }

    @Override
    public List<Income> loadList() {
        return incomeMapper.loadList();
    }

    @Override
    public Income selectById(int incomeId) {
        return incomeMapper.selectById(incomeId);
    }

    @Override
    public int delete(int incomeId) {
        return incomeMapper.delete(incomeId);
    }

    @Override
    public int update(Income income) {
        return incomeMapper.update(income);
    }

    @Override
    public int sum(Income income) {
        if (incomeMapper.sum(income) == null){
            return 0;
        }else {
            return incomeMapper.sum(income);
        }
    }

//    @Override
//    public int sumByMonth(@Param("userId") int userId, @Param("month") int month) {
//        return incomeMapper.sumByMonth(userId,month);
//    }

}
